﻿@using SCMS.Resources
@model SCMS.UI.Models.EditAsset
@using SCMS.CoreBusinessLogic.Settings
@{AjaxOptions ajaxOpts = new AjaxOptions
  {
      UpdateTargetId = "popup-page",
      LoadingElementId = "popup-loading",
      HttpMethod = "Post",
      Url = Url.Action("EditAssetDetails"),
      OnBegin = string.Format("ShowDialogue('{0}')", Resources_frank.Inventory_LoadEditAsset_ItemDetails),
      OnSuccess = "CenterPopup"
  };}
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Ajax.BeginForm(null, null, ajaxOpts, new { @class = "form", enctype = "multipart/form-data" }))
{
    @Html.ValidationSummary(true)
    <fieldset>
        @Html.HiddenFor(x => x.EntityAsset.Id)
        @Html.HiddenFor(x => x.EntityAsset.CountryProgramId)
        @Html.HiddenFor(x => x.EntityAsset.ItemId)
        @Html.HiddenFor(x => x.EntityAsset.GoodsReceivedNoteItemId)
        @Html.HiddenFor(x => x.EntityAsset.DepreciationCurrencyId)
        @Html.HiddenFor(x => x.EntityAsset.AcquisionDate)
        @{ const string currentOwner = "Not Assigned";}
        @*@{ string currentOwner = Resources_frank.Global_String_NotAssigned;}*@
        <table>
            <tr>
                <td align="left" valign="top" class="editor-label">
                    @Resources_frank.Global_String_AssetDescription:
                </td>
                <td align="left" class="editor-field" colspan="3">
                    @Html.TextAreaFor(x => x.EntityAsset.Name)
                    @Html.ValidationMessageFor(x => x.EntityAsset.Name)
                </td>
            </tr>
            <tr>
                <td align="left" valign="top" class="editor-label">
                    @Resources_morgan.Global_String_AssetNo
                </td>
                <td align="left" class="editor-field">
                    @Html.EditorFor(x => x.EntityAsset.AssetNumber)
                    @Html.ValidationMessageFor(x => x.EntityAsset.AssetNumber)
                </td>
                <td align="left" valign="top" class="editor-label">
                    @Resources_morgan.Global_String_SerialNo
                </td>
                <td align="left" class="editor-field">
                    @Html.EditorFor(x => x.EntityAsset.SerialNumber)
                    @Html.ValidationMessageFor(x => x.EntityAsset.SerialNumber)
                </td>
            </tr>
            <tr>
                <td align="left" valign="top" class="editor-label">
                    @Resources_frank.Global_String_EstLifespan
                </td>
                <td align="left" class="editor-field">
                    @Html.TextBoxFor(x => x.EntityAsset.Lifespan)
                    @Html.ValidationMessageFor(x => x.EntityAsset.Lifespan)
                    <label>
                        @Html.CheckBoxFor(x => x.EntityAsset.UseLifeSpan)
                        @Resources_frank.Global_String_UseEstLifespan</label>
                </td>
                <td align="left" valign="top" class="editor-label">
                    @Resources_frank.Global_String_WeightInKg:
                </td>
                <td align="left" class="editor-field">
                    @Html.EditorFor(x => x.EntityAsset.Weight)
                    @Html.ValidationMessageFor(x => x.EntityAsset.Weight)
                </td>
            </tr>
            <tr>
                <td align="left" valign="top" class="editor-label">
                    @Resources_frank.GoodsReceivedNote_LoadOtherAssets_PurchasePrice
                </td>
                <td align="left" class="editor-field">
                    @Html.TextBoxFor(x => x.EntityAsset.PurchaseValue, new { @disabled = "disabled", id = "purcahseValue" })
                    @Html.ValidationMessageFor(x => x.EntityAsset.PurchaseValue)
                </td>
                <td align="left" valign="top" class="editor-label">
                    @Resources_frank.GoodsReceivedNote_GRAssetList_SalvageValue
                </td>
                <td align="left" class="editor-field">
                    @Html.TextBoxFor(x => x.EntityAsset.SalvageValue, new { onblur = "javascript:ValidateSalvageValue(this);" })
                    @Html.ValidationMessageFor(x => x.EntityAsset.SalvageValue)
                </td>
            </tr>
            <tr>
                <td align="left" valign="top" class="editor-label">
                    @Resources_frank.GoodsReceivedNote_LoadOtherAssets_PercentageDep (%)
                </td>
                <td align="left" class="editor-field">
                    @Html.TextBoxFor(x => x.EntityAsset.PercentageDepr)
                    @Html.ValidationMessageFor(x => x.EntityAsset.PercentageDepr)
                </td>
                <td align="left" valign="top" class="editor-label">
                    @Resources_frank.GoodsReceivedNote_LoadRegisterAsset_OpeningAccDep
                </td>
                <td align="left" class="editor-field" valign="top">
                    @Html.EditorFor(x => x.EntityAsset.OpeningAccDepreciaiton)
                    @Html.ValidationMessageFor(x => x.EntityAsset.OpeningAccDepreciaiton)
                </td>
            </tr>
            <tr>
                <td align="left" valign="top" class="editor-label">
                    @Resources_morgan.Global_String_Warehouse
                </td>
                <td align="left" class="editor-field">
                    @Html.DropDownListFor(x => x.EntityAsset.CurrentWareHouseId, Model.Warehouses, Resources_frank.Global_String_PleaseSelect)
                    @Html.ValidationMessageFor(x => x.EntityAsset.CurrentWareHouseId)
                </td>
                <td align="left" valign="top" class="editor-label">
                    Depreciation Type
                </td>
                <td align="left" class="editor-field">
                    @Html.DropDownListFor(x => x.EntityAsset.DepreciationType, new SelectList(
                  new List<Object>{ 
                       new { value = "Straight Line" , text = Resources_frank.Global_DepreciationType_StraightLine  },
                       new { value = "Reducing Balance" , text = Resources_frank.Global_DepreciationType_ReducingBalance },
                       new { value = "Zero Balance" , text = Resources_frank.Global_DepreciationType_ZeroBalance}
                    }, "value", "text"), Resources_frank.Global_String_PleaseSelect)
                    @Html.ValidationMessageFor(x => x.EntityAsset.DepreciationType)
                </td>
            </tr>
            <tr>
                <td align="left" class="editor-label">
                    @Resources_frank.Inventory_LoadEditAsset_CurrentOwner
                </td>
                <td align="left" class="editor-field">
                    @if (Model.EntityAsset.CurrentOwnerId != null)
                    {
                        @Html.DropDownListFor(x => x.EntityAsset.CurrentOwnerId, Model.Staffs, Resources_frank.Global_String_PleaseSelect)
                        @Html.ValidationMessageFor(x => x.EntityAsset.CurrentOwnerId)
                    }
                    else
                    { @currentOwner}
                </td>
                <td align="left" valign="top" class="editor-label">
                    @Resources_frank.Global_String_CurrentProject
                </td>
                <td align="left" class="editor-field">
                    @*@ViewBag.CurrentProject*@
                    @Html.DropDownListFor(x => x.EntityAsset.CurrentProjectDonorId, Model.Projects, Resources_frank.Global_String_PleaseSelect)
                    @Html.ValidationMessageFor(x => x.EntityAsset.CurrentProjectDonorId)
                    @*@Html.HiddenFor(x => x.EntityAsset.CurrentProjectDonorId)*@
                </td>
            </tr>
            <tr>
                <td align="left" valign="top" class="editor-label">
                    @Resources_frank.GoodsReceivedNote_LoadOtherAssets_IsFleet
                </td>
                <td align="left" class="editor-field">
                    @Html.EditorFor(x => x.EntityAsset.IsFleet)
                    @Html.ValidationMessageFor(x => x.EntityAsset.IsFleet, Resources_frank.Global_String_Required)
                </td>
                <td align="left" valign="top" class="editor-label">
                    @Resources_frank.Global_String_Picture
                </td>
                <td align="left" class="editor-field">
                    <input type="file" name="@Html.FieldNameFor(model => model.AssetPictureUpload)" />
                    <br />
                    @Resources_frank.Global_String_MaxSize: @(SettingsHelper<CommonSettings>.Settings.PersonPhotoMaxSize)
                    @Resources_frank.Global_String_KB (@(SettingsHelper<CommonSettings>.Settings.AllowedImageExtensions.StringJoin("", ",")))<br />
                    @Html.ValidationMessageFor(model => model.AssetPictureUpload)
                </td>
            </tr>
        </table>
        <center>
            <input type="submit" class="btn green" value="@Resources_frank.Global_String_Save" /></center>
    </fieldset> }
